@extends('layouts.console_header')

@section('title', '商家回评列表')

@section('resources')
    @parent
    <style>
        .user_list_search{overflow: hidden;margin: 10px 20px;}
        .user_list_search span{float: left;color: #808080;}
        .user_list_search input{float: right;width: 200px;height: 30px;border: 1px solid #000;}
        .user_list_search .user_list_searchbtn{float: right;height: 30px;margin-left: 10px;width: 50px;background-color: #9955c6;color: #fff;border: none;}
        .user_list_pageouter{overflow: hidden;background-color: #fff;}
        .user_list_page{float: right;overflow: hidden;}
        .user_list_page a{float: left;width: 40px;height: 30px;line-height: 30px;text-align: center;}
        .user_list_page .show{background-color: #eee;border: 1px solid #ccc;}
        .display{text-align: center;background-color: #fff;border-collapse:collapse;}
        .display th{padding: 20px 0;}
        .display #tbody_content{border-top: 1px solid #000;border-bottom: 1px solid #000;font-size: 14px;}
        .display #tbody_content tr:nth-child(2n+1){border-bottom: 1px solid #ddd;background-color: #f9f9f9;}
        .display #tbody_content tr:nth-child(2n){border-bottom: 1px solid #ddd;}
        .display #tbody_content tr td{padding: 10px 0;}
        .display #tbody_content tr td:nth-child(1){background-color: #f1f1f1;}
        nav{height: 50px;line-height: 50px;}
        nav a,nav span{margin-left: 20px;}
        nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
    </style>
@endsection

@section('content')
<section class="user_list">
    <p class="fz_14 account_title">
        <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>订单管理></span>
        <span class="co_violet">商家回评列表</span>
    </p>
    <nav>
        <a class="fl" href="/console/order/business/review?cityid={{$cityid}}&type=today">今日</a>
        <a class="fl" href="/console/order/business/review?cityid={{$cityid}}&type=yesterday">昨日</a>
        <a class="fl" href="/console/order/business/review?cityid={{$cityid}}&type=week">本周</a>
        <a class="fl" href="/console/order/business/review?cityid={{$cityid}}&type=thismonth">本月</a>
        <a class="fl" href="/console/order/business/review?cityid={{$cityid}}&type=lastmonth">上月</a>
        <a class="fl" href="/console/order/business/review?cityid={{$cityid}}&type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>
    <p class="user_list_search">
        <span>合计：{{$total}}条记录</span>
        <input class="user_list_searchbtn" type="button" name="submit_search" value="搜索">
        <input type="text" name="search" value="" placeholder="搜索">
    </p>
    <table class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>序号</th>
                <th>订单号</th>
                <th>用户昵称</th>
                <th>用户账号</th>

                <th>门店名称</th>
                <th>回评时间</th>
                <th>回评内容</th>
                <th>操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
               <th>序号</th>
               <th>订单号</th>
               <th>用户昵称</th>
               <th>用户账号</th>
               <th>门店名称</th>
               <th>回评时间</th>
               <th>回评内容</th>
               <th>操作</th>
            </tr>
        </tfoot>
        <tbody id="tbody_content">
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    <td>{{$list['ordernumber']}}</td>
                    <td>{{$list['nickname']}}</td>
                    <td>{{$list['mobile']}}</td>
                    <td>{{$list['shopname']}}</td>
                    <td>{{date('Y-m-d H:i', strtotime($list['replytime']))}}</td>
                    <td>{{$list['replycontent']}}</td>
                    <td><a class="co_red delete_btn" href="#" onclick="delete_review('{{$list['commentid']}}')">删除</a></td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <div class="user_list_pageouter">
        <p class="user_list_page">
            <a href="/console/order/business/review?cityid={{$cityid}}&page=1&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">首页</a>
            @if($lastpage <=5)
                @for($i=1; $i<=$lastpage; $i++)
                    @if($page == $i)
                        <a href="/console/order/business/review?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$i}}</a>
                    @else
                        <a href="/console/order/business/review?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$i}}</a>
                    @endif
                @endfor
            @else
                @if($page>2)
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page-2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-2}}</a>
                @endif
                @if($page>1)
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page-1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-1}}</a>
                @endif
                <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$page}}</a>
                @if(($page+5)<$lastpage)
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page+1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+1}}</a>
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page+2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+2}}</a>
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page+3}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+3}}</a>
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page+4}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+4}}</a>
                    <a href="">....</a>
                    <a href="/console/order/business/review?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$lastpage}}</a>
                @else
                    @for($i=1; $i<=5;$i++)
                        @if($page+$i<=$lastpage)
                            <a href="/console/order/business/review?cityid={{$cityid}}&page={{$page+$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+$i}}</a>
                        @endif
                    @endfor
                @endif
            @endif
            <a href="/console/order/business/review?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">末页</a>
        </p>
    </div>
</section>
<ul class="delete">
    <li>
        <span>确认</span>
        <img class="fr" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    </li>
    <li>确定删除评论内容么？</li>
    <li>
        <input type="hidden" name="commentid" value="">
        <button style="background-color: #9955c6;color: #fff;" class="fl delete_sure">确定</button>
        <button class="fr delete_cancel">取消</button>
    </li>
</ul>
@endsection

@section('scriptResources')
    @parent
<script>
    var cityid='{{$cityid}}';
    var str = window.location.href;
    if(str.indexOf("today") > 0){
        $("nav a").eq(0).css({"color": "#9955c6"});
    }else if(str.indexOf("yesterday") > 0){
        $("nav a").eq(1).css({"color": "#9955c6"});
    }else if(str.indexOf("week") > 0){
        $("nav a").eq(2).css({"color": "#9955c6"});
    }else if(str.indexOf("thismonth") > 0){
        $("nav a").eq(3).css({"color": "#9955c6"});
    }else if(str.indexOf("lastmonth") > 0){
        $("nav a").eq(4).css({"color": "#9955c6"});
    }else if(str.indexOf("all") > 0){
        $("nav a").eq(5).css({"color": "#9955c6"});
    }
    function delete_review(comment_id) {
        $(".delete input[name='commentid']").val(comment_id);
        $(".delete").show();
    }
    $(".delete li img").click(function(){
        $(".delete").hide();
    })
    $(".delete_cancel").click(function(){
        $(".delete").hide();
    })
    $(".delete_sure").click(function() {
        var commentid = $(".delete input[name='commentid']").val();
        $.ajax({
            url : "/console/order/business/review/delete",
            type : "post",
            data : {
                "cityid" : cityid,
                "commentid" : commentid
            },
            dataType: "json",
            success:function (data){
                if(data.status == 'success') {
                    alert(data.message);
                    window.location.reload();
                } else {
                    alert(data.message);
                }
            }
        });
    })
    function select_date() {
        var startTime = $("input[name='starttime']").val();
        var lastTime = $("input[name='lasttime']").val();
        if(!startTime || !lastTime) {
            alert('请选择开始时间和结束时间'); return;
        }
        window.location.href="/console/order/business/review?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
    }
    $(".user_list_searchbtn").click(function() {
        var search=$("input[name='search']").val();
        if(search == '') {
            return;
        }
        window.location.href = "/console/order/business/review?cityid="+cityid+"&search="+search+"&now=" + Date.parse(new Date());
    });
</script>
@endsection